#include "epollServer.hpp"
#include <memory>
using std::unique_ptr;
int myread(int sock)
{
    char buff[1024];
    ssize_t s = recv(sock, buff, sizeof(buff) - 1, 0);
    if (s > 0)
    {
        buff[s] = 0;
        logMessage(DEBUG, "client[%d]# %s", sock, buff);
    }
    return s;
}
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        cout << "Usage:" << argv[0] << " port" << endl;
        exit(1);
    }
    int port = atoi(argv[1]);
    unique_ptr<EpollServer> uptr(new EpollServer(port, myread));
    uptr->InitEpollServer();
    uptr->Run();

    return 0;
}